//返回顶部的效果
var top1 = document.querySelector('#top1');
console.log(document.body.scrollTop);
//滚动事件，滚动一次就会执行一次
window.onscroll = function(){
    console.log(document.body.scrollTop);
//    判断它距离顶部的位置
    if(document.body.scrollTop > 100){
        top1.style.display = 'block';
    }else{
        top1.style.display = 'none';
    }
};
top1.addEventListener('click',function(){
//    滚动到指定的位置
//    支持老版的Chorme浏览器
    window.scrollTo(0,0);


    //支持新版的Chorme浏览器
    window.scrollTo({
        top:0,
        behavior:'smooth'
    })
});



//移入，移除效果
//获取div
//分类的效果
var cation = document.querySelector("#cation");
var details = document.querySelector("#details");
//移入分类按钮
cation.addEventListener("mouseover",function(){
    //显示分类详情
    details.style.display = 'block';
});
//移出分类按钮
cation.addEventListener("mouseleave",function(){
    //关闭分类详情
    details.style.display = 'none';
});
//移入详情
details.addEventListener("mouseover",function(){
    //分类详情不关闭
    details.style.display = 'block';
});
//移出详情
details.addEventListener("mouseleave",function(){
    //分类详情关闭
    details.style.display = 'none';
});

//更多的效果
var gd1 = document.querySelector("#gd1");
var gd2 = document.querySelector("#gd2");
gd1.addEventListener("mouseover",function(){
    gd2.style.display = 'block';
});
gd1.addEventListener("mouseleave",function(){
    gd2.style.display = 'none';
});
gd2.addEventListener("mouseover",function(){
    gd2.style.display = 'block';
});
gd2.addEventListener("mouseleave",function(){
    gd2.style.display = 'none';
});




//点赞的效果
var num = document.querySelector("#zan").innerHTML;
var zan2 = 'zh';
function zan(){
    num = Number(num);

    if (zan2 == 'zh'){
        zan2 = 'en';
    }else{
        zan2 = 'zh';
    }

    if (zan2 == 'en'){
        document.querySelector("#zan").innerHTML = num +1;
        document.querySelector("#z").style.color = "#ff5754";
    }else{
        document.querySelector("#zan").innerHTML = num;
        document.querySelector("#z").style.color = "#000";
    }


}
//收藏的效果
var num2 = document.querySelector("#like").innerHTML;
var like2 = 'zh';
function like(){
    num2 = Number(num2);

    if (like2 == 'zh'){
        like2 = 'en';
    }else{
        like2 = 'zh';
    }

    if (like2 == 'en'){
        document.querySelector("#like").innerHTML = num2+1;
        document.querySelector("#l").style.color = "#1cbdf2";
    }else{
        document.querySelector("#like").innerHTML = num2;
        document.querySelector("#l").style.color = "#000";
    }
}




//轮播图
var mySwiper = new Swiper ('.swiper-container', {
    loop: true, // 循环模式选项
    autoplay:true, //自动切换
    effect : 'fade', //切换效果
    keyboard : true, //键盘效果
    mousewheel: true, //鼠标滚轮效果
    zoom : true, //双击放大效果


    //延迟加载效果
    lazy: {
        loadPrevNext: true,
    },

    // 如果需要分页器
    pagination: {
        el: '.swiper-pagination',
        clickable:true,
    },

    // 如果需要前进后退按钮
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },
});
var lbo1 = document.querySelector("#lbo1");
var lbo2 = document.querySelector("#lbo2");
lbo1.addEventListener("mouseover",function(){
    lbo2.style.display = 'block';
});
lbo1.addEventListener("mouseleave",function(){
    lbo2.style.display = 'none';
});